package com.zr.d_c.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.d_c.service.DishService;
import com.zr.d_c.serviceimpl.DishServiceImpl;

import net.sf.json.JSONArray;
/**
 * 商家删除菜品
 * @author Administrator
 *
 */
public class DeleteDishController extends HttpServlet {
	DishService dishservice = new DishServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter pw = resp.getWriter();
		String[] dids = req.getParameterValues("did[]");
		int[] did = new int[dids.length];
		for (int i = 0; i < dids.length; i++) {
			did[i] = Integer.parseInt(dids[i]);
		}
		if(dishservice.deleteDishByDid(did)){
			pw.write("1");
		}else{
			pw.write("0");
		}
	}

}
